<?php

/**
 * instruction-paie/planning-content.phtml
 * Contenu du tableau de l'instruction de paie
 */
use RHX\Helper\Number;
?>
<?php
$instructions	 = $this->instructions;
$jaune		 = 1;
$jaune1		 = '#FFF67F';
$jaune2		 = '#FFEE05';
$colorJaune	 = '';
$refMutuelle	 = $this->refMutuelle;
foreach ($instructions as $inst):
    if(!$inst->id){$inst->id = -1 ;};
    
    $colorJaune	 = (($jaune % 2) == 0) ? $jaune2 : $jaune1;
    $employe	 = $inst->getEmploye();
    $contrat	 = $employe->getContratType();
    $poste		 = $employe->getPoste();
    $site		 = $employe->getSite();
    $hebdo		 = $employe->getHoraireHebdo();
    $mensualite	 = $hebdo * 4;
    $taux		 = $employe->getTaux();
    ?>
    <tr>
        <td style='background: <?php echo $colorJaune; ?>;'>
	    <?php echo $employe->getMatricule(true); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][matricule]" value="<?php echo $employe->matricule; ?>">
        </td>
        <td style='background: <?php echo $colorJaune; ?>;'><?php echo $employe->nom1; ?></td>
        <td style='background: <?php echo $colorJaune; ?>;'><?php echo $employe->prenom; ?></td>
        <td style='background: <?php echo $colorJaune; ?>;'><?php echo $contrat->abrev; ?></td>
        <td style='background: <?php echo $colorJaune; ?>;'><?php echo Number::getSiteLibelle($site->libelle); ?></td>
        <td style='background: <?php echo $colorJaune; ?>;'><?php echo $poste->code; ?></td>
        <td>
	    <?php echo number_format($inst->mensualite, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][mensualite]" id='form-<?php echo $employe->matricule; ?>-mensualite' value="<?php echo $inst->mensualite; ?>">
        </td>
        <td>
	    <?php echo number_format($hebdo, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][hebdo]" id='form-<?php echo $employe->matricule; ?>-hedbo' value="<?php echo $hebdo; ?>">
        </td>
        <td>
	    <?php echo number_format($taux, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][taux]" id='form-<?php echo $employe->matricule; ?>-taux' value="<?php echo $taux; ?>">
        </td>
        <td>
	    <?php echo $inst->anciennete ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][anciennete]" value="<?php echo str_replace(',', '.', $inst->anciennete); ?>">
        </td>
        <td>
    	<!-- Heure complémentaire -->
    	<span title="<?php echo $inst->hc_debug; ?>"><?php echo ((int) $inst->heure_comptabilise == 0) ? '' : Number::frenchFormat($inst->heure_comptabilise); ?></span>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_comptabilise]" id='form-<?php echo $employe->matricule; ?>-hc' value="<?php echo $inst->heure_comptabilise; ?>">
        </td>
        <td>
    	<!-- Heure complémentaire + Heures supplémentaires 25 % -->
    	<span title="<?php echo $inst->hs_debug; ?>"><?php echo ((int) $inst->heure_comptabilise_heure_supplementaire == 0) ? '' : Number::frenchFormat($inst->heure_comptabilise_heure_supplementaire); ?></span>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_comptabilise_heure_supplementaire]" id='form-<?php echo $employe->matricule; ?>-hs25' value="<?php echo $inst->heure_comptabilise_heure_supplementaire; ?>">
        </td>
        <td>
    	<!-- Heures supplémentaires 50 % -->
	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="heure_supplementaire" data-pk="<?php echo $inst->id ?>" id="heure_supplementaire-<?php echo $employe->matricule ?>"><?php echo Number::frenchFormat($inst->heure_supplementaire); ?></a>
	    <?php //echo Number::frenchFormat(0.0); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_supplementaire]" id="form-<?php echo $employe->matricule ?>-heure_supplementaire" value="<?php echo $inst->heure_supplementaire; ?>">
        </td>
        <td>
	    <?php echo ((int) $inst->ferie == 0) ? '' : number_format($inst->ferie, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][ferie]" id='form-<?php echo $employe->matricule; ?>-ferie' value="<?php echo $inst->ferie; ?>">
        </td>
        <td>
	    <?php echo ((int) $inst->dimanches == 0) ? '' : number_format($inst->dimanches, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][dimanches]" id='form-<?php echo $employe->matricule; ?>-dimanches' value="<?php echo $inst->dimanches; ?>">
        </td>
        <td>
    	<!-- Libellé des heures majorés à 100% -->
    	<a href="#" class="instr-edit" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="heure_positive_libelle" data-pk="<?php echo $inst->id ?>" id="heure_positive_libelle-<?php echo $employe->matricule ?>"><?php echo $inst->heure_positive_libelle; ?></a>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_positive_libelle]" id="form-<?php echo $employe->matricule ?>-heure_positive_libelle" value="<?php echo addslashes($inst->heure_positive_libelle); ?>">
        </td>
        <td>
	    <?php echo ((int) $inst->heure_negative == 0) ? '' : number_format($inst->heure_negative, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_negative]" id='form-<?php echo $employe->matricule ?>-negative' value="<?php echo $inst->heure_negative; ?>">
        </td>
        <td>
    	<!-- Libellé & AM -->
    	<a href="#" class="instr-edit" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="heure_negative_libelle" data-pk="<?php echo $inst->id; ?>" id="heure_negative_libelle-<?php echo $employe->matricule ?>"><?php echo $inst->heure_negative_libelle ?></a>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][heure_negative_libelle]" id="form-<?php echo $employe->matricule; ?>-hnl" value="<?php echo addslashes($inst->heure_negative_libelle); ?>">
        </td>
        <td>
	    <?php echo ((int) $inst->am1_jour == 0) ? '' : number_format($inst->am1_jour, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][am1_jour]" value="<?php echo $inst->am1_jour; ?>">
        </td>
        <td>
	    <?php echo ((int) $inst->am1_heure == 0) ? '' : number_format($inst->am1_heure, 2, ',', ' '); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule ?>][am1_heure]" value="<?php echo $inst->am1_heure; ?>">
        </td>
        <td>
    	<!-- dont régul M-1 -->
	    <?php echo ((int) $inst->heure_module_m1) ? '' : Number::frenchFormat($inst->heure_module_m1); ?>
    	<input type="hidden" name="instr[<?php echo $employe->matricule; ?>][heure_module_m1]" value="<?php echo $inst->heure_module_m1; ?>">
        </td>
        <td>
	    <?php echo number_format($inst->heure_module_css, 2, ',', ' '); ?>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][heure_module_css]' id='form-<?php echo $employe->matricule ?>-css' value='<?php echo $inst->heure_module_css; ?>'>
        </td>
        <td>
    	<!-- Libellé CSS -->
    	<a href='#' class='instr-edit' data-pk="<?php echo $inst->id; ?>" data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='css_libelle' id="css_libelle-<?php echo $employe->matricule ?>"><?php echo $inst->css_libelle; ?></a>
    	<input type='hidden' name='instr[<?php echo $employe->matricule; ?>][css_libelle]' id='form-<?php echo $employe->matricule ?>-css_libelle' value='<?php echo addslashes($inst->css_libelle); ?>'>
        </td>
        <td>
	    <?php echo number_format($inst->css_jour, 2, ',', ' '); ?>
    	<input type='hidden' name='instr[<?php echo $employe->matricule; ?>][css_jour]' value="<?php echo $inst->css_jour; ?>">
        </td>
        <td>
    	<!-- Laboratoire -->
        </td>
        <td>
    	<!-- Entree/Sortie -->
        <a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="entree_sortie_heure" data-pk="<?php echo $inst->id ?>" id="entree_sortie_heure-<?php echo $employe->matricule ?>"><?php echo Number::frenchFormat($inst->entree_sortie_heure); ?></a>
	    <?php //echo number_format($inst->entree_sortie_heure, 2, ',', ' '); ?>
	<input type="hidden" name="instr[<?php echo $employe->matricule; ?>][entree_sortie_heure]" value='<?php echo $inst->entree_sortie_heure; ?>'>
        </td>
        <td>
	    <?php echo number_format($inst->at_heure, 2, ',', ' '); ?>
    	<input type='hidden' name='instr[<?php echo $employe->matricule; ?>][at_heure]' value='<?php echo $inst->at_heure; ?>'>
        </td>
        <td>
	    <?php echo number_format($inst->cm_heure, 2, ',', ' '); ?>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][cm_heure]' value='<?php echo $inst->cm_heure; ?>'>
        </td>
        <td>
	    <?php echo number_format($inst->am2_heure, 2, ',', ' '); ?>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][am2_heure]' value='<?php echo $inst->am2_heure; ?>'>
        </td>
        <td>
    	<!-- Libellé Maintien salaire -->
    	<a href="#" class="instr-edit" data-group="<?php echo $inst->group; ?>" data-pk="<?php echo $inst->id; ?>" data-id="<?php echo $employe->matricule ?>" data-name="maintient_libelle"><?php echo $inst->maintient_libelle; ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][maintient_libelle]' id='maintient_libelle' value='<?php echo addslashes($inst->maintient_libelle); ?>'>
        </td>
        <td>
	    <?php echo $inst->cp_jour; ?>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][cp_jour]' value='<?php echo $inst->cp_jour; ?>'>
        </td>
        <td>
	    <?php echo Number::frenchFormat($inst->cp_heure); ?>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][cp_heure]' value='<?php echo $inst->cp_heure; ?>'>
        </td>
        <td>
    	<a href="#" class="instr-edit" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="cp_libelle" data-pk="<?php echo $inst->id; ?>"><?php echo $inst->cp_libelle; ?><?php echo $inst->cp_libelle; ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][cp_libelle]' value='<?php echo addslashes($inst->cp_libelle); ?>'>
        </td>
        <td>
    	<!-- Montant CP -->
	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="prime_montant" data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->prime_montant); ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][prime_montant]' id='form-<?php echo $employe->matricule ?>-prime_montant' value='<?php echo $inst->prime_montant; ?>'>
        </td>
        <td>
    	<!-- Libellé CP -->
    	<a href="#" class="instr-edit-cp" data-type="select" data-id="<?php echo $employe->matricule ?>" data-name="prime_libelle" data-pk="<?php echo $inst->id; ?>"><?php echo $inst->prime_libelle; ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][prime_libelle]' id='form-<?php echo $employe->matricule ?>-prime_libelle' value='<?php echo addslashes($inst->prime_libelle); ?>'>
        </td>
        <td>
    	<!-- Montant hors CP -->
    	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="prime_montant_hors_cp" data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->prime_montant_hors_cp); ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][prime_montant_hors_cp]' id='form-<?php echo $employe->matricule ?>-prime_montant_hors_cp' value='<?php echo $inst->prime_montant_hors_cp; ?>'>
        </td>
        <td>
    	<!-- Libellé hors CP -->
    	<a href="#" class="instr-edit-hcp" data-group="<?php echo $inst->group; ?>" data-type="select" data-id="<?php echo $employe->matricule ?>" data-name="prime_libelle_hors_cp" data-pk="<?php echo $inst->id; ?>"><?php echo $inst->prime_libelle_hors_cp; ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][prime_libelle_hors_cp]' id='form-<?php echo $employe->matricule ?>-prime_libelle_hors_cp' value='<?php echo addslashes($inst->prime_libelle_hors_cp); ?>'>
        </td>
        <td>
    	<!-- Participation -->
	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="participation" data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->participation); ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][participation]' id='form-<?php echo $employe->matricule ?>-participation' value='<?php echo $inst->participation; ?>'>
        </td>
        <td>
    	<!-- DIFF Montant -->
    	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="hors_temps_travail_montant" data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->hors_temps_travail_montant); ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][hors_temps_travail_montant]' id='form-<?php echo $employe->matricule ?>-hors_temps_travail_montant' value='<?php echo $inst->hors_temps_travail_montant; ?>'>
        </td>
        <td>
    	<!-- DIFF Libelle -->
    	<a href="#" class="instr-edit" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="hors_temps_travail_libelle" data-pk="<?php echo $inst->id; ?>"><?php echo $inst->hors_temps_travail_libelle; ?></a>
    	<input type="hidden" name='instr[<?php echo $employe->matricule; ?>][hors_temps_travail_libelle]' id='form-<?php echo $employe->matricule ?>-hors_temps_travail_libelle' value='<?php echo addslashes($inst->hors_temps_travail_libelle); ?>'>
        </td>
        <td>
	    <?php echo $inst->repas; ?>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][repas]" id='form-<?php echo $employe->matricule ?>-repas' value="<?php echo $inst->repas; ?>">
        </td>
        <td>
	    <?php
	    $mutuelle	 = $employe->getMutuelle();
	    $boolMutuelle	 = $refMutuelle->id == $mutuelle->id;
	    ?>
    	<a href="#" class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id="<?php echo $employe->matricule ?>" data-name="mutuelle" data-pk="<?php echo $inst->id; ?>" title="<?php echo $mutuelle->libelle; ?>">
		<?php if ($boolMutuelle): ?>
		    <?php echo Number::frenchFormat($refMutuelle->valeur); ?>
		<?php else: ?>
		    0,00
		<?php endif; ?>
    	</a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][mutuelle]" id='form-<?php echo $employe->matricule ?>-mutuelle' value="<?php echo ($boolMutuelle) ? $refMutuelle->valeur : 0.0; ?>">
        </td>
        <td>
    	<!-- Vehicule -->
	<a href='#' class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='vehicule' data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->vehicule); ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][vehicule]" id='form-<?php echo $employe->matricule ?>-vehicule' value='<?php echo $inst->vehicule; ?>'>
        </td>
        <td>
    	<!-- Logement -->
    	<a href='#' class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='logement' data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->logement); ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][logement]" id='form-<?php echo $employe->matricule ?>-logement' value='<?php echo $inst->logement; ?>'>
        </td>
        <td>
    	<!-- IJSS Montant -->
    	<a href='#' class="instr-edit-int" data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='ijss_brute_montant' data-pk="<?php echo $inst->id; ?>"><?php echo Number::frenchFormat($inst->ijss_brute_montant); ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][ijss_brute_montant]" id='form-<?php echo $employe->matricule ?>-ijss_brute_montant' value='<?php echo $inst->ijss_brute_montant; ?>'>
        </td>
        <td>
    	<!-- IJSS Libelle -->
    	<a href='#' class="instr-edit" data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='ijss_brute_libelle' data-pk="<?php echo $inst->id; ?>"><?php echo $inst->ijss_brute_libelle; ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][ijss_brute_libelle]" id='form-<?php echo $employe->matricule ?>-ijss_brute_libelle' value='<?php echo addslashes($inst->ijss_brute_libelle); ?>'>
        </td>
        <td>
    	<!-- Base CO -->
	    <?php echo ($inst->base_co != 0) ? Number::frenchFormat($inst->base_co) : '' ?>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][base_co]" value="<?php echo $inst->base_co; ?>">
        </td>
        <td>
    	<!-- IJSS Net -->
    	<a href='#' class='instr-edit-int' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='ijss_net' data-pk="<?php echo $inst->id; ?>"><?php echo ($inst->ijss_net != 0) ? Number::frenchFormat($inst->ijss_net) : '' ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][ijss_net]" id='form-<?php echo $employe->matricule ?>-ijss_net' value="<?php echo $inst->ijss_net; ?>">
        </td>
        <td>
    	<!-- Acompte -->
    	<a href='#' class='instr-edit-int' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='acompte' data-pk="<?php echo $inst->id; ?>"><?php echo ($inst->acompte != 0) ? Number::frenchFormat($inst->acompte) : '' ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][acompte]" id='form-<?php echo $employe->matricule ?>-acompte' value="<?php echo $inst->acompte; ?>">
        </td>
        <td>
    	<!-- Pret -->
    	<a href='#' class='instr-edit-int' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='pret' data-pk="<?php echo $inst->id; ?>"><?php echo ($inst->pret != 0) ? Number::frenchFormat($inst->pret) : '' ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][pret]" id='form-<?php echo $employe->matricule ?>-pret' value="<?php echo $inst->pret; ?>">
        </td>
        <td>
    	<!-- ATD -->
    	<a href='#' class='instr-edit-int' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='atd' data-pk="<?php echo $inst->id; ?>"><?php echo ($inst->atd != 0) ? Number::frenchFormat($inst->atd) : '' ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][atd]" id='form-<?php echo $employe->matricule ?>-atd' value="<?php echo $inst->atd; ?>">
        </td>
        <td>
    	<!-- Changement Contrat -->
	    <?php echo $inst->changement_contrat; ?>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][changement_contrat]" value="<?php echo $inst->changement_contrat; ?>">
        </td>
        <td>
    	<!-- Commentaire 1 -->
    	<a href='#' class='instr-edit' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='commentaire1' data-pk="<?php echo $inst->id; ?>"><?php echo $inst->commentaire1 ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][commentaire1]" id="form-<?php echo $employe->matricule ?>-commentaire1" value="<?php echo addslashes($inst->commentaire1); ?>">
        </td>
        <td>
    	<!-- Commentaire 2 -->
    	<a href='#' class='instr-edit' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='commentaire2' data-pk="<?php echo $inst->id; ?>"><?php echo $inst->commentaire2 ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][commentaire2]" id="form-<?php echo $employe->matricule ?>-commentaire2" value="<?php echo addslashes($inst->commentaire2); ?>">
        </td>
        <td>
    	<!-- Commentaire 3 -->
    	<a href='#' class='instr-edit' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='commentaire3' data-pk="<?php echo $inst->id; ?>"><?php echo $inst->commentaire3 ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][commentaire3]" id="form-<?php echo $employe->matricule ?>-commentaire3" value="<?php echo addslashes($inst->commentaire3); ?>">
        </td>
        <td>
    	<!-- Commentaire 4 -->
    	<a href='#' class='instr-edit' data-group="<?php echo $inst->group; ?>" data-id='<?php echo $employe->matricule; ?>' data-name='commentaire4' data-pk="<?php echo $inst->id; ?>"><?php echo $inst->commentaire4 ?></a>
    	<input type='hidden' name="instr[<?php echo $employe->matricule; ?>][commentaire4]" id="form-<?php echo $employe->matricule ?>-commentaire4" value="<?php echo addslashes($inst->commentaire4); ?>">
        </td>
        <td>
    	<!--span style="font-weight: bold;" id="salaire-<?php echo $employe->matricule ?>"><?php echo number_format($inst->salaire_brute, 2, ',', ''); ?></span-->
    	<!--input type="hidden" name="instr[<?php echo $employe->matricule ?>][salaire_brute]" id="form-<?php echo $employe->matricule ?>-salaire_brute" value="<?php echo $inst->salaire_brute; ?>"-->
            
        <span style="font-weight: bold;" class='inst-salaire-text' id="salaire-<?php echo $inst->id?>"><?php echo number_format($inst->salaire_brute, 2, ',', ''); ?></span>
        <input type="hidden" class='inst-salaire-form'  name="instr[<?php echo $employe->matricule ?>][salaire_brute]" id="form-<?php echo $inst->id ?>-salaire_brute" value="<?php echo $inst->salaire_brute; ?>">
        </td>
	<td>
	    <?php echo 'Mod.' .$inst->mode_calcul; ?>
	</td>
    </tr>
    <?php $jaune++; ?>
<?php endforeach; ?>
<!--tr>
    <td>
	<input type="hidden" name="periode" value="<?php echo $this->periode; ?>">
	<input type="hidden" name="site" value="<?php echo $this->site; ?>">
    </td>
</tr-->
<script type="text/javascript">
    $(function() {
        /* MAJ des attribut 'data-pk' des lien editable d'une ligne
         * utilisé après une insertion de ligne via ajax
         * liens concerné a.instr-edit a.instr-edit-int
         */
        var maj_data_pk = function($oDom, value){ 
                                var $trParent = $oDom.parent().parent();
                                $trParent.find('td a').each(function(){
                                    $a = $(this);
                                    if($a.is('[data-pk]')){ // has data-pk attribute
                                        $a.attr('data-pk', value );
                                    }
                                });
                            },
          update_number = function(objCall){ 
                            var objDef = { "thisA" : null, "url": null, "value": null};
                            obj = $.extend(objDef , objCall) ;
                            if( ! (obj.thisA && obj.url && obj.value) )
                                return false;
                            
                            var $thisA = obj.thisA,
                                url    = obj.url,
                                value  = obj.value;                              
                            pk      = $thisA.attr('data-pk');
                            name    = $thisA.attr('data-name');
                            data = 'pk='+pk+ '&name='+name+'&value=' + value;
                            
                            $ajax = $.ajax({
                                type: 'post', url: url, data: data, async: false
                                           });                            
                          }; 
                            
	$('.instr-edit').editable({
	    title: 'Edition',	    
            url : function (params){
                update_number({
                               'thisA'  : $(this),  
                               'url'   : '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'updateString')) ?>',                                
                               'value' : params.value,
                              }) ;
            },
	    validate: function(value1) {
                var $thisA = $(this);
                
		id = $thisA.attr('data-id');
		name = $thisA.attr('data-name');
		selector = '#form-' + id + '-' + name;
		$(selector).val(value1);		
		pk = parseInt($(this).attr('data-pk'));
                
		if (pk < 0) {
		    name = $(this).attr('data-name');
		    group = $(this).attr('data-group');
		    $ajax = $.ajax({
			type: 'post',
			url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'insert')) ?>',
			data: '&value=' + value1 + '&name=' + name + '&matricule=' + id + '&group=' + group + '&periode=<?php echo $this->periode; ?>',
			async: false
		    });
		    $ajax.done(function(result) {
                        /* // obloslete
			selector = '#' + name + '-' + id;
			$(selector).attr('data-pk', result.paie.id);*/
                        
                        var paye_id = result.paie.id;                                                                               
                        maj_data_pk($thisA, paye_id);   
		    });
		}
	    },success: function() {
		
                var $thisA  = $(this),                
                    pk      = $thisA.attr('data-pk');
                
                //salaireCalculEx($thisA, pk);// bug must be pk
	    }
	});
	$('.instr-edit-int').editable({
	    title: 'Edition',	    
            url : function (params){
                update_number({
                               'thisA'  : $(this),  
                               'url'   : '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'updateNumber')) ?>',                                
                               'value' : params.value,
                              }) ;
            },
	    validate: function(value2) {
                var $thisA = $(this);
                
		id      = $thisA.attr('data-id');
		name    = $thisA.attr('data-name');
                pk      = $thisA.attr('data-pk');
		selector = '#form-' + id + '-' + name;
                
		$(selector).val(replaceVirgule(value2));
                
		if (pk < 0) {
		    name = $(this).attr('data-name');
		    group = $(this).attr('data-group');
		    $ajax = $.ajax({
			type: 'post',
			url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'insert')) ?>',
			data: '&value=' + value2 + '&name=' + name + '&matricule=' + id + '&group=' + group + '&periode=<?php echo $this->periode; ?>',
			async: false
		    });
		    $ajax.done(function(result) {
                        /* // obsolete
			selector = '#' + name + '-' + id;
			$(selector).attr('data-pk', result.paie.id);
                        */
                       
                        // Maj des pk
                        var paye_id = result.paie.id;                                                                               
                        maj_data_pk($thisA, paye_id);                        
		    });
		}
	    },
	    tpl: "<input type='text' onKeyPress='validateNumber(event);'>",
	    success: function() {
		//salaireCalcul(id);// bug must be pk
                var $thisA  = $(this),                
                    pk      = $thisA.attr('data-pk');
                
                salaireCalculEx($thisA, pk);// bug must be pk
	    }
	});
	$('.instr-edit-cp').editable({
	    title: 'Prime',
	    source: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'primeCP')) ?>',
	    validate: function(value3) {
		id = $(this).attr('data-id');
		name = $(this).attr('data-name');
		ajax = $.ajax({
		    type: 'post',
		    url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'primeInfo')) ?>',
		    data: '&id=' + value3
		});
		ajax.done(function(result) {
		    info = result.info;
		    selector = '#form-' + id + '-' + name;
		    $(selector).val(info.libelle);
		    $('#form-' + id + '-prime_montant').val(info.valeur);
		    $('#form-' + id + '-prime_montant').parent().find(':first-child').text(info.valeur);
		});
	    }
	});
	$('.instr-edit-hcp').editable({
	    title: 'Prime',
	    source: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'primeHCP')) ?>',
	    validate: function(value) {
		id = $(this).attr('data-id');
		name = $(this).attr('data-name');
		ajax = $.ajax({
		    type: 'post',
		    url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'primeInfo')) ?>',
		    data: '&id=' + value
		});
		ajax.done(function(result) {
		    info = result.info;
		    selector = '#form-' + id + '-' + name;
		    $(selector).val(info.libelle);
		    $('#form-' + id + '-prime_montant_hors_cp').val(info.valeur);
		    $('#form-' + id + '-prime_montant_hors_cp').parent().find(':first-child').text(info.valeur);
		});
	    }
	});
	// Indicateur de nouveau
<?php if ($this->action == RHX\Model\Object\InstructionPaie::CREATE): ?>
    	$('#action').html("*");
<?php elseif ($this->action == RHX\Model\Object\InstructionPaie::VIEW): ?>
    	$('#action').html("**");
<?php endif; ?>
    });
    function calculSalaire(id) {
	selector = '#form-' + id;
	heureMensuel = parseFloat($(selector + '-mensualite').val());//alert('Heure Mensuel : ' + heureMensuel);
	heureComplementaire = parseFloat($(selector + '-hc').val());
	heureSupplementaire25 = parseFloat($(selector + '-hs25').val());
	heureSupplementaire50 = parseFloat($(selector + '-hs').val());
	ferie = parseFloat($(selector + '-ferie').val());
	dimanche = parseFloat($(selector + '-dimanches').val());
	modulationNegative = parseFloat($(selector + '-negative').val());
	modulationCss = parseFloat($(selector + '-css').val());
	entreeSortie = 0.0;
	taux = parseFloat($(selector + '-taux').val());
	montantCp = parseFloat($(selector + '-prime_montant').val());
	montantHorsCP = parseFloat($(selector + '-prime_montant_hors_cp').val());
	dif = parseFloat($(selector + '-hors_temps_travail_montant').val());
	repas = parseFloat($(selector + '-repas').val());
	mutuelle = parseFloat($(selector + '-mutuelle').val());
	vehicule = parseFloat($(selector + '-vehicule').val());
	logement = parseFloat($(selector + '-logement').val());
	ijssBrute = parseFloat($(selector + '-ijss_brute_montant').val());
	salaire = (((heureMensuel + heureComplementaire + (heureSupplementaire25 * 1.25) + (heureSupplementaire50 * 1.5) + ferie + dimanche - Math.abs(modulationNegative) - Math.abs(modulationCss) - Math.abs(entreeSortie))) * taux) + montantCp + dif + (repas * 3.44) + mutuelle + vehicule + logement + ijssBrute;
	$(selector + '-salaire_brute').val(salaire);
	$("#salaire-" + id).text(salaire);
	////alert(salaire);
    }
    function salaireCalcul(id) {
	selector = '#form-' + id;
	$ajax = $.ajax({
	    type: 'post',
	    url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'salaire')) ?>',
	    data: '&id=' + id
	});
	$ajax.done(function(result) {
	    $(selector + '-salaire_brute').val(result.salaire);
	    $("#salaire-" + id).text(result.salaire);
	});
    }
    
    function salaireCalculEx($linkCell, pkInst ) {
	var $trParent = $linkCell.parent().parent();
        
	$ajax = $.ajax({
	    type: 'post',
	    url: '<?php echo $this->url('RHX/default', array('controller' => 'instructionpaie', 'action' => 'salaire')) ?>',
	    data: '&id=' + pkInst
	});
	$ajax.done(function(result) {	   
            var salaire = result.salaire;
            
            $trParent.find('td .inst-salaire-text').text( salaire );
            $trParent.find('td .inst-salaire-form').val(salaire );
	});
    }
</script>